/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PatientListUnmodifiable.java
 *
 * Created on Oct 23, 2011, 6:12:34 PM
 */
package pkg1;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;

/**
 * Objects of this class represent views displaying a list of patients
 * overseen by a provider.
 * @author Nick
 */
public class PatientList extends javax.swing.JFrame {

    /** Creates new form PatientList */
    public PatientList(Provider p) {
        provider = p;
        initComponents();
    }

    /**
     * Initializes the components of the GUI.
     */
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        model = new DefaultListModel();
        setUpModel();
        jList1.setModel(model);
        jScrollPane1.setViewportView(jList1);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("Assigned Patients:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
                    .addComponent(jLabel1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(13, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>

    /**
     * Sets up the list of the patients
     */
    private void setUpModel() {
        for(Patient p : provider.getPatients()) {
            model.addElement(p);
        }
    }
    // Variables declaration
    private javax.swing.JLabel jLabel1;
    private DefaultListModel model;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    //The provider whose list of patients is displayed
    private Provider provider;
    // End of variables declaration
}
